package com.nettest.util;

import java.util.Map;

import org.apache.struts2.util.StrutsTypeConverter;

public class MyDoubleConvert extends StrutsTypeConverter {

	@SuppressWarnings("rawtypes")
	@Override
	public Object convertFromString(Map context, String[] values, Class toClass) {

		if (Double.class == toClass) {
			String doubleStr = values[0];
			if (doubleStr != null && !"".equals(doubleStr)) {
				return Double.parseDouble(doubleStr);
			}
		}
		return new Double(0);
	}

	@Override
	@SuppressWarnings("rawtypes")
	public String convertToString(Map context, Object o) {
		return o.toString();
	}

}
